package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyBackgroundColorBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class BackgroundColorAdapter extends StkProviderMultiAdapter<MyBackgroundColorBean> {

    public BackgroundColorAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(80));
        addItemProvider(new BackgroundColorProvider());
    }

    private class BackgroundColorProvider extends BaseItemProvider<MyBackgroundColorBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_background_color;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyBackgroundColorBean bean) {
            baseViewHolder.setBackgroundColor(R.id.tvBackgroundColorItemColor, Color.parseColor(bean.getColor()));
            if (bean.isSelect()) {
                baseViewHolder.getView(R.id.ivBackgroundColorItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivBackgroundColorItemSel).setVisibility(View.GONE);
            }
        }
    }
}
